package com.archgeek.java.conc.future;

import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import org.apache.commons.lang3.RandomUtils;

import java.util.concurrent.TimeUnit;

/**
 * @author pizhihui
 * @date 2024-03-08 14:24
 */
public class CFutureTools {


    public static void doRandomTask(String taskName) {

        System.out.println(DateUtil.now() + ":" + taskName + ",开始");

        int i = RandomUtils.nextInt(5, 10);

        try {
            TimeUnit.SECONDS.sleep(i);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }

        System.out.println(DateUtil.now() + ":" + taskName + ",结束");
    }


}
